<template>
  <div class="FlowAdd-container">
    <div style="width: 2px;height: 90px;background-color: #dedede;position: absolute;top: 0px;"></div>
    <a-tooltip placement="rightTop">
      <template #title>
        <div>
          <div class="pointer" @click="addType(1)">审核人</div>
          <div class="pointer" @click="addType(2)">抄送人</div>
          <div class="pointer" @click="addType(4)">条件分支</div>
        </div>
      </template>
      <component class="fs-30 icon-btn c-primaryColor pointer" is="plus-circle-filled"></component>
    </a-tooltip>
  </div>
</template>

<script lang="ts" setup>
import {computed, ref} from "vue";
import {randomString} from "@/utils/common";

const props = defineProps({
  node: {
    type: Object,
    default: {}
  }
})
const emits = defineEmits(['update:node'])

const nodeConfig = computed({
  get() {
    return props.node
  },
  set(value) {
    emits('update:node', value)
  },
})
const addType = (type: number) => {
  if (type !== 4) {
    let data
    if (type === 1) {
      data = {
        'pkId': randomString(),
        'nodeName': '审核人',
        'error': true,
        'type': 1,
        'settype': 1,
        'selectMode': 0,
        'selectRange': 0,
        'directorLevel': 1,
        'replaceByUp': 0,
        'examineMode': 1,
        'noHanderAction': 1,
        'examineEndDirectorLevel': 0,
        'colnumPermissions': [],
        'childNode': nodeConfig.value.childNode,
        'nodeUserList': [],
        'conditionModel': 0,
        'selectProject': '',
        'selectBill': ''
      }
    } else if (type === 2) {
      data = {
        'pkId': randomString(),
        'nodeName': '抄送人',
        'type': 2,
        'ccSelfSelectFlag': 1,
        'childNode': nodeConfig.value.childNode,
        'nodeUserList': []
      }
    }
    nodeConfig.value.childNode = data
    emits('update:node', nodeConfig.value)
  } else {
    let data = {
      'pkId': randomString(),
      'nodeName': '路由',
      'type': 4,
      'childNode': nodeConfig.value.childNode,
      'conditionNodes': [{
        'pkId': randomString(),
        'nodeName': '条件1',
        'error': true,
        'type': 3,
        'priorityLevel': 1,
        'conditionModel': 1,
        'conditionList': [],
        'nodeUserList': [],
        'childNode': {}
      }, {
        'pkId': randomString(),
        'nodeName': '条件2',
        'type': 3,
        'priorityLevel': 2,
        'conditionModel': 2,
        'conditionList': [],
        'nodeUserList': [],
        'childNode': {}
      }]
    }
    nodeConfig.value.childNode = data
    emits('update:node', nodeConfig.value)
  }
}

</script>

<style lang="less" scoped>
.FlowAdd-container {
  display: flex;
  justify-content: center;
  padding: 30px 0;
  position: relative;

  .icon-btn {
    position: relative;
    z-index: 20;
    background-color: #ffffff;
    border-radius: 50%;
  }

  // &:before {
  //   content: '';
  //   display: block;
  //   position: absolute;
  //   top: 0;
  //   right: 0;
  //   bottom: 0;
  //   left: 0;
  //   width: 2px;
  //   background-color: #dedede;
  //   margin: auto;
  //   z-index: 10;
  // }
}
</style>
